marshallgrads Absent Member.
Absent Member.
1458 views

How to use Date/Time Feature

Reflection version used to record Macro: 14.0
Reflection version used to run Macro: MICRO FOCUS REFELCTION Desktop Pro v16.0 SP-1

Wanted to post some uses of the date/time feature for people who might want to build macros and use a data or time

Sub DATETEST()
' Generated by the Reflection Macro Recorder on 09-26-2013 12:42:18.76.
' Generated by Reflection for UNIX and OpenVMS 14.0.6.
On Error GoTo ErrorHandler

Const NEVER_TIME_OUT = 0

Dim LF As String ' Chr(rcLF) = Chr(10) = Control-J
Dim CR As String ' Chr(rcCR) = Chr(13) = Control-M

LF = Chr(Reflection2.ControlCodes.rcLF)
CR = Chr(Reflection2.ControlCodes.rcCR)

With Session

'==================================================================
'Format(expression[, format[, firstdayofweek[, firstweekofyear]]])
'==================================================================

'THIS SIMPLY GIVE YOU THE DATE IN THE FORMAT OF mM/dD/YYYY (ex: 9/16/2013)
.MsgBox Date

'THIS WILL SIMPLY GIVE YOU THE DAY OF THE WEEK (ex: THURSDAY)
.MsgBox "FORMAT OF DATE IS dddd >> " & Format(Date, "dddd")
.MsgBox "FORMAT OF THE DATE IS ddd >>> " & Format(Date, "ddd")
.MsgBox "FORMAT OF THE DATE IS dd >>> " & Format(Date, "dd")
.MsgBox "FORMAT OF THE DATE IS d >>> " & Format(Date, "d")

'FORMAT WILL BE "Thursday, September 26, 2013"
.MsgBox "FORMAT OF THE DATE IS Long Date >>> " & Format(Date, "Long Date")
.MsgBox "FORMAT OF THE DATE IS Short Date >>> " & Format(Date, "Short Date")

'FORMAT WILL BE "Thursday, Sep 26 2013"
'NOTICE NOT COMMA AFTER DATE. AND MONTH IS ABBREVIATED TO 3 LETTERS
.MsgBox Format(Date, "dddd, mmm d yyyy")

'THIS WILL RETURN A NUMBER FORM 1-7 IDENTIFYING THE WEEKDAY.
'EXAMPLE THE 4TH WEEK OF THE MONTH OF September
.MsgBox "FORMAT OF THE DATE IS (w FOR WEEKDAY) >> " & Format(Date, "w")

'THIS WILL RETUNR A NUMBER FROM 1-12 IDENTIFYING THE MONTH
.MsgBox "FORMAT OF THE DATE IS (m FOR MONTH) >> " & Format(Date, "m")

'THIS WILL GIVE THE JULIAN DAY OF THE YEAR.
.MsgBox "FORMAT OF THE DATE IS (y FOR JULIAN DAY) >> " & Format(Date, "y")

'THIS FORMAT IS SUPPOSED TO BE ABLE TO FIGURE LEAP YEARS OUT. HAVE NOT WORKED WITH IT ENOUGH.
'IT IS A BOOLEAN STATEMENT AND RETURNS A TRUE OR FALSE I BELIEVE???
'LEAP YEARS ARE SUPPOSED TO BE 2008, 2012, 2016, 2020, 2024, ETC...
'.MsgBox (29 = Day(DateSerial(intYear, 2, 29)))
.MsgBox (29 = Day(DateSerial(2016, 2, 29)))

.MsgBox "BUTCH " & Format(Date, "w")


End With

Exit Sub

ErrorHandler:
Session.MsgBox Err.Description, vbExclamation + vbOKOnly

' Recording stopped at 12:42:30.65.
End Sub
0 Likes
3 Replies
AutomaticReply Absent Member.
Absent Member.

Re: How to use Date/Time Feature

marshallgrads,

It appears that in the past few days you have not received a response to your
posting. That concerns us, and has triggered this automated reply.

These forums are peer-to-peer, best effort, volunteer run and that if your issue
is urgent or not getting a response, you might try one of the following options:

- Visit https://www.microfocus.com/support-and-services and search the knowledgebase and/or check
all the other self support options and support programs available.
- Open a service request: https://www.microfocus.com/support
- You could also try posting your message again. Make sure it is posted in the
correct newsgroup. (http://forums.microfocus.com)
- You might consider hiring a local partner to assist you.
https://www.partnernetprogram.com/partnerfinder/find.html

Be sure to read the forum FAQ about what to expect in the way of responses:
http://forums.microfocus.com/faq.php

Sometimes this automatic posting will alert someone that can respond.

If this is a reply to a duplicate posting or otherwise posted in error, please
ignore and accept our apologies and rest assured we will issue a stern reprimand
to our posting bot.

Good luck!

Your Micro Focus Forums Team
http://forums.microfocus.com



0 Likes
vfast Absent Member.
Absent Member.

Re: How to use Date/Time Feature

Nice example! Keep in mind that the VBA environment also provides "MsgBox", so it is not actually necessary to use the ".MsgBox" method that is part of the Reflection "Session" object. The old Reflection Basic language also has MsgBox, so I don't know why Reflection developers decided to add that, seems unnecessary.
0 Likes
marshallgrads Absent Member.
Absent Member.

Re: How to use Date/Time Feature

Thanks Vfast. The version above was recorded/written in the older legacy Reflection product (v14). During my writing it was simply easier for me to use the embedded VBA code that the Reflection offered at the time. Both statements work equally well in the older version but it appears that only the VB version (msgbox) and not the (.msgbox) works now with the new product (Micro Focus Reflection - Desktop Pro v16).:)
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.