DateToDmy, DateToDmyHms and TimeToHms Commands

Purpose

Returns the day, month, year and/or hour, minute, and seconds of a Date/Time value.

Syntax

DateToDmy date, day, month, year
DateToDmyHms date, day, month, year, hour, minute, second
TimeToHms date, hour, minute, second

date: date expression
day, month, year,
hour, minute, second
: integer expressions

Description

These commands are shortcuts for Day(), Month(), Year(), Hour(), Minute(), and Second() functions and assign the specified part of a Date/Time value to a pre-defined integer variable. See the example below for how to use them.

Example

OpenW 1

Global Int d, m, y, h, mn, s

DateToDmy Date - 25, d, m, y            // Returns the date 25 days ago

PrintResult(1)

DateToDmyHms Now, d, m , y, h, mn, s    // Returns the date and time now

PrintResult(3)

TimeToHms Now - (1 / 24), h, mn, s      // Returns the time one hour ago

PrintResult(2)

Do : Sleep : Until Me Is Nothing

 

Sub PrintResult(part%)

If Btst(part%, 0) Then Print "Day: "; d, "Month: "; m, "Year: "; y;

If Btst(part%, 1) Then Print Tab(45); "Hour: "; h, "Minute: "; mn, "Second: "; s

If Not Btst(part%, 1) Then Print

EndSub

See Also

CDate(), Date, Date$, DateAdd(), DateDiff(), DatePart(), DateSerial(), DateTime$(), DateValue(), Day(), DayNo(), DmyHmsToDate(), DmyToDate(), HmsToTime(), Hour(), IsDate(), Minute(), Month(), Now, Now$(), TimeSerial(), TimeValue(), Second(), Week(), WeekDay(), Year()

{Created by Sjouke Hamstra; Last updated: 13/02/2016 by James Gaite}