I am importing a file into a datawindow, and my first row contains column headings. Some of these headings are dates and I need to change the format before using the dates as the text of datawindow column headings. I have the following code, but the date is not displaying correctly.
In my test file, the dates used are: 6-Jun-2009,13-Jun-2009,20-Jun-2009,27-Jun-2009,4-Jul-2009
The results I see are: 1/1/00, 6/13/20, 6/20/20, 6/27/20, 1/1/00
// Get all dates
ll_weekNum = 1
Do while ll_weekNum <=5
ls_columnName = "week" + String(ll_weekNum)
ls_date = dw_file_viewer.getitemstring(1,ls_columnName)
choose case ll_weekNum
case 1
ls_week1 = ls_date
case 2
ls_week2 = ls_date
case 3
ls_week3 = ls_date
case 4
ls_week4 = ls_date
case else
ls_week5 = ls_date
end choose
ll_weekNum ++
Loop
// Convert Strings to dates
RegistryGet("HKEY_CURRENT_USER\Control Panel\International", "sShortDate", ls_shortdate) //storing user's date setting
RegistrySet("HKEY_CURRENT_USER\Control Panel\International", "sShortDate", "d-Mmm-yyyy")
id_week1 = Date(ls_week1)
id_week2 = Date(ls_week2)
id_week3 = Date(ls_week3)
id_week4 = Date(ls_week4)
id_week5 = Date(ls_week5)
// Convert dates to correct format
RegistrySet("HKEY_CURRENT_USER\Control Panel\International", "sShortDate", ls_shortdate)
// Convert dates to strings
ls_week1 = String(id_week1)
ls_week2 = String(id_week2)
ls_week3 = String(id_week3)
ls_week4 = String(id_week4)
ls_week5 = String(id_week5)
// Update column headings with new dates
ll_weekNum = 1
Do while ll_weekNum <=5
choose case ll_weekNum
case 1
ls_modify = "week1_t.text =~' " + ls_week1 + "~' "
case 2
ls_modify = "week2_t.text =~' " + ls_week2 + "~' "
case 3
ls_modify = "week3_t.text =~' " + ls_week3 + "~' "
case 4
ls_modify = "week4_t.text =~' " + ls_week4 + "~' "
case else
ls_modify = "week5_t.text =~' " + ls_week5 + "~' "
end choose
dw_file_viewer.Modify(ls_Modify)
ll_weekNum ++
Loop
In my test file, the dates used are: 6-Jun-2009,13-Jun-2009,20-Jun-2009,27-Jun-2009,4-Jul-2009
The results I see are: 1/1/00, 6/13/20, 6/20/20, 6/27/20, 1/1/00
// Get all dates
ll_weekNum = 1
Do while ll_weekNum <=5
ls_columnName = "week" + String(ll_weekNum)
ls_date = dw_file_viewer.getitemstring(1,ls_columnName)
choose case ll_weekNum
case 1
ls_week1 = ls_date
case 2
ls_week2 = ls_date
case 3
ls_week3 = ls_date
case 4
ls_week4 = ls_date
case else
ls_week5 = ls_date
end choose
ll_weekNum ++
Loop
// Convert Strings to dates
RegistryGet("HKEY_CURRENT_USER\Control Panel\International", "sShortDate", ls_shortdate) //storing user's date setting
RegistrySet("HKEY_CURRENT_USER\Control Panel\International", "sShortDate", "d-Mmm-yyyy")
id_week1 = Date(ls_week1)
id_week2 = Date(ls_week2)
id_week3 = Date(ls_week3)
id_week4 = Date(ls_week4)
id_week5 = Date(ls_week5)
// Convert dates to correct format
RegistrySet("HKEY_CURRENT_USER\Control Panel\International", "sShortDate", ls_shortdate)
// Convert dates to strings
ls_week1 = String(id_week1)
ls_week2 = String(id_week2)
ls_week3 = String(id_week3)
ls_week4 = String(id_week4)
ls_week5 = String(id_week5)
// Update column headings with new dates
ll_weekNum = 1
Do while ll_weekNum <=5
choose case ll_weekNum
case 1
ls_modify = "week1_t.text =~' " + ls_week1 + "~' "
case 2
ls_modify = "week2_t.text =~' " + ls_week2 + "~' "
case 3
ls_modify = "week3_t.text =~' " + ls_week3 + "~' "
case 4
ls_modify = "week4_t.text =~' " + ls_week4 + "~' "
case else
ls_modify = "week5_t.text =~' " + ls_week5 + "~' "
end choose
dw_file_viewer.Modify(ls_Modify)
ll_weekNum ++
Loop