Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
date data types
Hello,
In my program, the user selects a year (exp: "2004") from a combo box. What I need to do is take the selected year and add a 9 months and 1 day to make the date be 9/1/2004. I am using the dateadd function for this. However, I use the CSng to change the "2004" to 2004. That works fine, but the CDate changes the 2004 to 6/26/1905. why is this? Any thoughts? crop_yeara = CSng(Crop_Year) Crop_Year1 = CDate(crop_yeara) crop_year2 = DateAdd("m", 9, crop_year1) thanks in advance for your help, Bill |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
date data types
Hi Bill
change the second line to =CDATE("1/1/" & cropyeara) and the third line to crop_year2 = DateAdd("m", 8, crop_year1) to get the 9/1/2004 or in one single line try: crop_year2 = DateAdd("m",8,"1/1/" & Crop_Year) HTH Frank Bill wrote: Hello, In my program, the user selects a year (exp: "2004") from a combo box. What I need to do is take the selected year and add a 9 months and 1 day to make the date be 9/1/2004. I am using the dateadd function for this. However, I use the CSng to change the "2004" to 2004. That works fine, but the CDate changes the 2004 to 6/26/1905. why is this? Any thoughts? crop_yeara = CSng(Crop_Year) Crop_Year1 = CDate(crop_yeara) crop_year2 = DateAdd("m", 9, crop_year1) thanks in advance for your help, Bill |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
date data types
thanks Frank, that worked great
----- Frank Kabel wrote: ---- Hi Bil change the second line t =CDATE("1/1/" & cropyeara and the third line t crop_year2 = DateAdd("m", 8, crop_year1 to get the 9/1/200 or in one single line try crop_year2 = DateAdd("m",8,"1/1/" & Crop_Year HT Fran Bill wrote Hello In my program, the user selects a year (exp: "2004") from a comb box. What I need to do is take the selected year and add a 9 month and 1 day to make the date be 9/1/2004. I am using the datead function for this. However, I use the CSng to change the "2004" t 2004. That works fine, but the CDate changes the 2004 to 6/26/1905 why is this? Any thoughts crop_yeara = CSng(Crop_Year Crop_Year1 = CDate(crop_yeara crop_year2 = DateAdd("m", 9, crop_year1 thanks in advance for your help Bil |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I hide unused file types from file types list in save dial | Excel Discussion (Misc queries) | |||
Excel 2007 error "some chart types cannot be combined with other chart types. Select a different chart types" | Charts and Charting in Excel | |||
Data types when importing Excel data to SQLServer | Excel Discussion (Misc queries) | |||
Mixed data types in a cell | Excel Discussion (Misc queries) | |||
Test for 3 types of data | Excel Programming |