Python command: HSI Date

The hsidate commands in Python allow you to access and format date and time information. 

See Python commands for other commands you can use with GainSeeker.

Syntax

Example

Description/Remarks

New or changed in GainSeeker version

hsidate.day

day = hsidate.day

Returns current day of the month as an integer.

 

hsidate.dbdatetime()

dt = hsidate.dbdatetime()

Returns the DB-formatted current datetime as long integer.

Note: This returns a 17-digit integer. GainSeeker dates are stored as 16 character strings. When using this value to query the GainSeeker database, remove the seventeenth digit.

 

hsidate.dbdatetime(year, month, day, hour, minute, second, millisecond)

dt = hsidate.dbdatetime(2014, 10, 4, 5, 20, 45, 0)

Returns the DB-formatted datetime long integer given the input time.

Note: This returns a 17-digit integer. GainSeeker dates are stored as 16 character strings. When using this value to query the GainSeeker database, remove the seventeenth digit.

 

hsidate.dbdatetimestr()

print hsidate.dbdatetimestr()

Returns the DB-formatted current datetime string.

Note: This returns a 17-character string. GainSeeker dates are stored as 16 character strings. When using this value to query the GainSeeker database, remove the seventeenth character. When setting dataspc.datetime or datadms.datetime the seventeenth character is automatically ignored.

 

hsidate.dbdatetimestr(year, month, day, hour, minute, second, millisecond)

print hsidate.dbdatetimestr(2014, 10, 4, 5, 20, 45, 0)

Returns the DB-formatted datetime string given the input time.

Note: This returns a 17-character string. GainSeeker dates are stored as 16 character strings. When using this value to query the GainSeeker database, remove the seventeenth character. When setting dataspc.datetime or datadms.datetime the seventeenth character is automatically ignored.

 

hsidate.dispdate()

print hsidate.dispdate()

Returns a display string of the current date.

 

hsidate.dispdatetime()

print hsidate.dispdatetime()

Returns a display string of the current date and time.

 

hsidate.disptime()

print hsidate.disptime()

Returns a display string of the current time.

 

hsidate.format_to_db(datetimestring)

print hsidate.format_to_db('02-28-2015')

returns 20150228000000000

Returns a 17 digit long integer representing the datetime in a format used by the GainSeeker database.

Returns -1 if there was an error parsing the datetime.

 

hsidate.format_to_db(datetimestring, formatstr)

print hsidate.format_to_db('02-28-2015', 'MM-dd-yyyy')

returns 20150228000000000

Returns a 17 digit long integer representing the datetime in a format used by the GainSeeker database.

Returns -1 if there was an error parsing the datetime.

For datetime format string options, see https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx

 

hsidate.formatdbdate(input, includedate,includetime)

hsidate.formatdbdate(20120210, True, False)

returns 2/10/2012

Formats database datetime string into readable strings.

 

hsidate.hour

hr = hsidate.hour

Returns current hour as an integer (24-hour).

 

hsidate.millisecond

msec = hsidate.millisecond

Returns current millisecond as an integer.

 

hsidate.minute

min = hsidate.minute

Returns current minute as an integer.

 

hsidate.month

mnth = hsidate.month

Returns current month as an integer.

 

hsidate.second

sec = hsidate.second

Returns current second as an integer.

 

hsidate.validate(datetimestring)

if hsidate.validate("3/22/2013 8:59"):

     print "Valid date"

Returns True if a datetime string is valid, using standard cultural formatting. Otherwise it returns False.

 

hsidate.validate(datetimestring, format)

if hsidate.validate("3/22/2013", "m/dd/yyyy"):

     print "Valid date"

Returns True if a datetime string is valid, using the specified format. Otherwise it returns False.

See https://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx for more information on format strings.

 

hsidate.year

yr = hsidate.year

Returns the current year as an integer.