wzm
asked on
Convert String to Date - LotusScript
Hi,
In my notes designer. I got to convert a string to date. How could I do that. Cause the idea is to check those months.
* mth = integer
* strNewHire = "Feb"
* AttrMonth = "Dec"
If mth = Month(strNewHire) Then ...
If mth = Month(AttrMonth) Then mthNum = 0
Thanks
In my notes designer. I got to convert a string to date. How could I do that. Cause the idea is to check those months.
* mth = integer
* strNewHire = "Feb"
* AttrMonth = "Dec"
If mth = Month(strNewHire) Then ...
If mth = Month(AttrMonth) Then mthNum = 0
Thanks
ASKER
Nope... that's not.
You need to convert the String to a number using
Dim DateV As Variant
' Calculate the date value for October 8, 1996.
DateV = DateValue(trNewHire)
then use
month( DateV ) as a number.
If Notes can not interpret your Month Strings, you may have to use a loop or loopup with your Months hard coded , to extract the number of the month.
Dim DateV As Variant
' Calculate the date value for October 8, 1996.
DateV = DateValue(trNewHire)
then use
month( DateV ) as a number.
If Notes can not interpret your Month Strings, you may have to use a loop or loopup with your Months hard coded , to extract the number of the month.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Returns the date value represented by a string expression.
Syntax
DateValue ( stringExpr )
Elements
stringExpr
A string expression representing a date/time. stringExpr must be a String in a valid date/time format or else a Variant containing either a date/time value or a string value in date/time format. If you omit the year in stringExpr, DateValue uses the year in the current system date.
If stringExpr is a string whose date part contains only numbers and valid date separators, the operating system's international Short Date format determines the order in which the numbers are interpreted as month, day, and year values.
If you specify a 2-digit year designation (yy) in Notes or Domino, LotusScript interprets 50 through 99 as the years 1950 through 1999 and 00 through 49 as the years 2000 through 2049. For example, 88 and 1988 are equivalent year designations and 12 and 2012 are equivalent year designations.
If you specify a 2-digit year designation in SmartSuite, LotusScript interprets the years differently. For information on how each SmartSuite product interprets 2-digit year designations, see the online help entry entitled Year 2000. This entry appears on the Help menu of each SmartSuite product.
Return value
DateValue returns the date value represented by stringExpr.
The data type of the return value is a Variant of DataType 7 (Date/Time).
Usage
If the stringExpr argument specifies a time of day, DateValue validates the time, but omits it from the return value.
Language cross-reference
@TextToTime function in formula language
Example
See Also
LotusScript Language Reference: A through D
CDat function
Date function
Date statement
DateNumber function
Format function
Time function
TimeValue function
--------------------------
From the example
Dim birthDateV As Variant
' Calculate the date value for October 8, 1996.
birthDateV = DateValue("October 8, 1996")
' Print this value as a date string.
Print CDat(birthDateV) ' Prints 10/8/96
' Print the age this person reaches, in years,
' on this year's birthday.
Print Year(Today) - Year(birthDateV)
You should be able to extract the month the same way.
I hope this helps !