Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro that picks up a date in cell and adds a month to it. Now I
need to take the first date it picked up and create two new variables using that date. The first variable I need is to simply pick out the year from the first date Ie if FirstDate = 3/1/2006, I need myYear to be "2006". The second variable I need to set is the FirstDate in YYYY_MM format, ie "2006_03". How do you convert the date to these two formats? I've tried myYear = FirstDate(format, "YYYY") but get "Argument not optional" and myYear = FirstDate&format("YYYY") but get "Syntax error" |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
myYear = Format(FirstDate, "YYYY")
mySecondVariable = Format(FirstDate, "YYYY_MM") StephanieH wrote: I have a macro that picks up a date in cell and adds a month to it. Now I need to take the first date it picked up and create two new variables using that date. The first variable I need is to simply pick out the year from the first date Ie if FirstDate = 3/1/2006, I need myYear to be "2006". The second variable I need to set is the FirstDate in YYYY_MM format, ie "2006_03". How do you convert the date to these two formats? I've tried myYear = FirstDate(format, "YYYY") but get "Argument not optional" and myYear = FirstDate&format("YYYY") but get "Syntax error" |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
'----------------------------------------------------
Dim myYear as string dim MyYearMonth as string myYear = format(FirstDate,"yyyy") myYearMonth =f ormat(FirstDate,"yyyy_mm") '---------------------------------------------------- HTH -- AP "StephanieH" a écrit dans le message de news: ... I have a macro that picks up a date in cell and adds a month to it. Now I need to take the first date it picked up and create two new variables using that date. The first variable I need is to simply pick out the year from the first date Ie if FirstDate = 3/1/2006, I need myYear to be "2006". The second variable I need to set is the FirstDate in YYYY_MM format, ie "2006_03". How do you convert the date to these two formats? I've tried myYear = FirstDate(format, "YYYY") but get "Argument not optional" and myYear = FirstDate&format("YYYY") but get "Syntax error" |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I convert US date with 12hr format to European date 24hr | Excel Discussion (Misc queries) | |||
Is it possible to convert solar date to lunar date using excel? | Excel Discussion (Misc queries) | |||
How to convert Gregorian date into Hijri Date in Excel 2007? | Excel Discussion (Misc queries) | |||
Convert a julian gregorian date code into a regular date | Excel Worksheet Functions | |||
Convert date to length of time in months from set date | Excel Worksheet Functions |