Converts a string of date and time values into a format more usable to the user.
SqlDateCrack% ( sqlconn%, dateinfo, datetime$ )
where
Field | Description |
---|---|
year% | A number of a year in the range 1753 through 9999. |
quarter% | A number of a quarter of a year in the range 1 though 4. |
month% | A number of a month in the range 1 through 12. |
dayofyear% | A number of a day of a year in the range 1 through 366. Leap years are counted. |
day% | A number of a day of a month in the range 1 through 31. |
week% | A number of a week of a year in the range 1 through 54. Leap years are counted. |
weekday% | A number of the day of a week in the range 1 through 7 (Monday though Sunday). |
hour% | A number of an hour in the range 0 through 23. |
minute% | A number of a minute in the range 0 through 59. |
second% | A number of a second in the range 0 through 59. |
millisecond% | A number of a millisecond in the range 0 through 999. |
SUCCEED (1) or FAIL (0).
SqlDateCrack% converts a SQL Server DATETIME string into its integer components and puts them into a dateinfo structure.
Date and time values are maintained in an internal format that is not readily usable. For example, a time value is stored as the number of 300ths of a second since midnight, and a date value is stored as the number of days since January 1, 1900. The SqlDateCrack% function converts the internal value to something easily usable by an application.
'Put the statement into the command buffer. Result% = SqlCmd%(Sqlconn%, "SELECT name, crdate FROM master..sysdatabases") 'Send the statement to SQL Server and start execution. Result% = SqlExec%(Sqlconn%) 'Process the statement results. Result% = SqlResults%(Sqlconn%) 'Retrieve and print the database name and its date info. DO UNTIL SqlNextRow%(Sqlconn%) = NOMOREROWS PRINT "Database Name is " PRINT SqlData$(Sqlconn%, 1) PRINT PRINT "Creation date string info is " PRINT SqlData$(Sqlconn%, 2) PRINT 'Break up the creation date into its constituent parts. Datetime$ = SqlData$(Sqlconn%, 2) SqlDateCrack(Sqlconn%, Dateinfo(), Datetime$) 'Print the parts of the creation date. PRINT PRINT "Year = "; Dateinfo.year PRINT "Month = "; Dateinfo.month PRINT "Day of month = "; Dateinfo.day PRINT "Day of year = "; Dateinfo.dayofyear PRINT "Day of week = "; Dateinfo.weekday PRINT "Hour = "; Dateinfo.hour PRINT "Minute = "; Dateinfo.minute PRINT "Second = "; Dateinfo.second PRINT "Millisecond = "; Dateinfo.millisecond LOOP