
lbDate = DateTime.Now()
lbDate = DateTime.Format(lbDate, "dd/MM/yyyy")
VarStartTime = DateTime.Now()
VarStartTime = DateTime.Format(VarStartTime, "hh:mm:ss")
Note:
lbDate – a label control that displays the current date in dd/MM/yyyy format.
VarStartTime – a string variable that contains the current time in hh:mm:ss format.
// Reset time assigned to listview query.
lvwActivity.QGetActivitiesToday.prmDateToday = DateTime.ResetTime(VarDateNow)
lvwActivity.Refresh()
Note:
lvwActivity.QGetActivitiesToday.prmDateToday – as the name implies, it is a listview query for lvwActivity with QGetActivitiesToday query linked to it. The query has a parameter called prmDateToday.
If only the date portion of the dateTime column is required it is best to reset the time of the column value before saving it to the database.
When retrieving dateTime column values, you can also reset the time portion so that the select statement will only compare dates.
Database.Reset()
Database.AddColumn("ID", intID)
VarDateTime = DateTime.SetDate(dtStartTime, 2000, 1, 1)
Database.AddColumn("START_TIME", VarDateTime)
VarDateTime = DateTime.SetDate(dtEndTime, 2000, 1, 1)
Database.AddColumn("END_TIME", VarDateTime)
VarDateTime = DateTime.SetTime(dtDateEntered, , 0, 0, 0)
Database.AddColumn("RESERVED_DATE", VarDateTime)
Database.AddColumn("RMNUM", VarRm)
Database.AddColumn("BLDG_CODE", VarBldg)
Database.AddRecord("RESERVATION")
Note:
This expression formats the dateTime columns by setting the time and date before adding the record to the database.
Ensure that you entered a valid time and date for the SetTime and SetDate methods respectively.
The AddRecord statement will not be successful if the dateTime values are invalid.
// Set created before to a day ahead (86400 seconds in a day)
dtBefore = DateTime.Now() + 86400
// Set created after to a week ago (604800 seconds in a week)
dtAfter = DateTime.Now() – 604800
Note:
You can use mathematical operations to manipulate the result of the dateTime value. Use the resulting values as a parameter value for searching reservations or jobs that was created within a specific time.
Remember: there are 24 hours in a day, 60 minutes per hour and 60 second per minute.