Date and Time Functions in Dicom Unit Conversion Calculator
Dicom conversion calculator has numerous built in date and time functions. Discussed here are some of the most commonly used ones:
- Cdate( [date_args] ) - returns date part of the date/time specified by the parameters
- Ctime( [date_args] ) - returns time part of the date/time specified by the parameters
- Cdatex( [date_args] ) - returns date and time specified by the parameters
date_args in each of the cases is optional. When date_args is omitted the functions return current date and time as appropriate.
That means:
- Cdate() = Current Date. The Today() function also produces same output.
- Ctime() = Current Time
- Cdatex() = Current Date and Time. The Now() function also returns same output.
Date Parameters
In place of date_args you can optionaly specify day, month, year, hour, minute and second.
date_args = day [, month [, [year [, [hour [, [minute [, second ] ] ] ] ] ]
The defults for missing parameters are assumed as month=January, year=0001, hour=00, minute=00, and second=00.
Thus, the valid syntaxes for the Cdate() function are:
Cdate() = current date
Cdate(20) = 20 January 0001
Cdate(20,2) = 20 February 0001
Cdate(20,2,2006) = 20 February 2006
Ctime() = current time
Ctime(20,2,2006) = 00:00:00
Ctime(20,2,2006,13) = 13:00:00
Ctime(20,2,2006,13,30) = 13:15:00
Ctime(20,2,2006,13,30,5) = 13:15:05
Cdatex() function works in a similar manner also.
There are many date/time related functions in dicom that require date_args, for example:
- Age( [date_args] ) - Seconds elapsed between current and speified date/time
- Cdow( [date_args] ) - Name of the day of the week
- Cmonth( [date_args] ) - Name of the month
- Day( [date_args] ) - Day of the month
- DayNum( [date_args] ) - Day serial of the year, 1 January being 1st day
- DaySerial( [date_args] ) - Day serial since 01-Jan-0001
- Dow( [date_args] ) - Day of the week (0=Sunday, 6=Saturday)
- DowISO( [date_args] ) - ISO day of the week (0=Moday, 6=Sunday)
- Month( [date_args] ) - Month no (1-12) of the year
- Second( [date_args] ) - Seconds elapsed since 01-Jan-0001 00:00:00
- WeekNum( [date_args] ) - Week no (1-52) of the year
- WeekNumISO( [date_args] ) - ISO week no (0-52) of the year
- Year( [date_args] ) - Year of the date
Note that in each of the above functions date_args are optional and if you don't specify it, current date/time will be assumed.
You can assign the ouput of Cdate(), Ctime() or Cdatex() functions to a memory variable and use that variable in place of date_args as well.
Example:
LandingOnMoon = Cdate(16, 7, 1969); TimePassed = Age(LandingOnMoon)
You may also use: Age(16, 7, 1969)
<< Home