### Get DateTime Now String

To get the current date and time, use the datetime object.
Example 1
'Get the current date and time as string - long version
`Sub GetDateTime As String
Dim now As Long
now = DateTime.now
Return DateTime.Date(now) & " " & DateTime.Time(now)
End Sub`
Example 2 = One Liner
Dim strCurrentDateTime As String = DateTime.Date(DateTime.now) & " " & DateTime.Time(DateTime.now)
Example 3 = One Liner using Smart Strings
Dim dt As String = $"${DateTime.Date(DateTime.now)} ${DateTime.Time(DateTime.now)}"$
Example 4 = Sub using Smart Strings
`Sub IsNow As String
Return $"${DateTime.date(DateTime.now)} ${DateTime.time(DateTime.now)}"$
End Sub`
Hint
To set the Dateformat use DateTime.DateFormat.
Examples:
DateTime.DateFormat = "dd.MM.yyyy"
DateTime.DateFormat = "yyyy-MM-dd"

Changed: , Category: DateTime, File: T6C183M1325.htm, ID: 1325