how can i convert date such as 20/03/2011 0r string 20032011 to twentieth march two thousand and eleven

you can use some built in string functions for a start.
but if you want that output, better have sub procedures that will generate the suffix for each word number.

try this (oracle code)

select to_char(sysdate,'ddspth fmmonth yyyysp') from dual

If dates are being stored in oracle DB then you may use this.

Edited 5 Years Ago by debasisdas: n/a

how can i convert date such as 20/03/2011 0r string 20032011 to twentieth march two thousand and eleven
if the database is stored in MSAccess

Edited 5 Years Ago by rajeshgs: n/a

you could create 3 labels and 2 command button

private sub cmdNow_click
lblday = ""
lblmonth = ""
lblyear = ""
lblday = format(now "dd")
lblmonth = format(now "mm")
lblyear = format(now "yyyy")
end sub
private sub lblday_change
if lblday = "1" then 
lblday = "1st"
end if
if lblday = "2" then 
lblday = "2nd"
end if
if lblday = "3" then 
lblday = "3rd"
end if
if val(lblday) = 3 to 31 then 
lblday = val(lblday) + "th"
end if
end sub
private sub lblmonth_change
if lblmonth = "1" then
ldlmonth = "genuary"
end if
if lblmonth = "2" then
ldlmonth = "february"
end if
if lblmonth = "3" then
ldlmonth = "march"
end if
if lblmonth = "4" then
ldlmonth = "april"
end if
if lblmonth = "5" then
ldlmonth = "may"
end if
if lblmonth = "6" then
ldlmonth = "june"
end if
if lblmonth = "7" then
ldlmonth = "july"
end if
if lblmonth = "8" then
ldlmonth = "august"
end if
if lblmonth = "9" then
ldlmonth = "september"
end if
if lblmonth = "10" then
ldlmonth = "october"
end if
if lblmonth = "11" then
ldlmonth = "november"
end if
if lblmonth = "12" then
ldlmonth = "december"
end if
end sub
private sub lblyear_change
lblyear = format(now "yyyysp")
end sub

if you don't want to use the today's date you have to create 3 textbox and use this code

private sub cmdNow_click
lblday = ""
lblmonth = ""
lblyear = ""
lblday = txtday
lblmonth = txtmonth
lblyear = txtyear
end sub
private sub lblday_change
if lblday = "1" then 
lblday = "1st"
end if
if lblday = "2" then 
lblday = "2nd"
end if
if lblday = "3" then 
lblday = "3rd"
end if
if val(lblday) = 3 to 31 then 
lblday = val(lblday) + "th"
end if
end sub
private sub lblmonth_change
if lblmonth = "1" then
ldlmonth = "genuary"
end if
if lblmonth = "2" then
ldlmonth = "february"
end if
if lblmonth = "3" then
ldlmonth = "march"
end if
if lblmonth = "4" then
ldlmonth = "april"
end if
if lblmonth = "5" then
ldlmonth = "may"
end if
if lblmonth = "6" then
ldlmonth = "june"
end if
if lblmonth = "7" then
ldlmonth = "july"
end if
if lblmonth = "8" then
ldlmonth = "august"
end if
if lblmonth = "9" then
ldlmonth = "september"
end if
if lblmonth = "10" then
ldlmonth = "october"
end if
if lblmonth = "11" then
ldlmonth = "november"
end if
if lblmonth = "12" then
ldlmonth = "december"
end if
end sub
private sub lblyear_change
lblyear = format(txtyear "yyyysp")
end sub

Edited 3 Years Ago by Nick Evan: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.