In PowerBuilder, you can use a variety of format strings to display date values as strings. Here’s a list of commonly used format strings:
- “MM/dd/yyyy”: Displays the month, day, and year in the format “mm/dd/yyyy”, with leading zeros for single-digit months and days.
- “dd/MM/yyyy”: Displays the day, month, and year in the format “dd/mm/yyyy”, with leading zeros for single-digit days and months.
- “yyyy-MM-dd”: Displays the year, month, and day in the format “yyyy-mm-dd”.
- “MM/dd/yyyy hh:mm:ss tt”: Displays the month, day, year, and time in the format “mm/dd/yyyy hh:mm:ss AM/PM”, with leading zeros for single-digit months, days, hours, minutes, and seconds.
- “MMM dd, yyyy”: Displays the month name, day, and year in the format “MMM dd, yyyy”.
- “MMMM dd, yyyy”: Displays the full month name, day, and year in the format “MMMM dd, yyyy”.
- “dd-MMM-yyyy”: Displays the day, month abbreviation, and year in the format “dd-MMM-yyyy”.
- “yyyy/MM/dd”: Displays the year, month, and day in the format “yyyy/mm/dd”.
These are just a few examples of the many format strings you can use to display date values as strings. You can adjust the format string to display the date in different formats, depending on your needs.
You can use the String()
function to convert a date value to a string. Here’s an example:
1 2 3 4 5 6 7 8 9 10 11 12 |
// Declare a date variable date ld_myDate // Assign a value to the date variable ld_myDate = Date(2023, 3, 17) // Convert the date variable to a string string ls_dateString ls_dateString = String(ld_myDate, "MM/dd/yyyy") // Display the string value MessageBox("Date as string", ls_dateString) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
// Declare a date variable date ld_myDate // Assign a value to the date variable ld_myDate = Date(2023, 3, 17) // Format the date as "MM/dd/yyyy" string ls_dateString1 ls_dateString1 = String(ld_myDate, "MM/dd/yyyy") // Format the date as "dd-MMM-yyyy" string ls_dateString2 ls_dateString2 = String(ld_myDate, "dd-MMM-yyyy") // Format the date as "yyyy/MM/dd" string ls_dateString3 ls_dateString3 = String(ld_myDate, "yyyy/MM/dd") // Display the formatted strings MessageBox("Formatted date 1", ls_dateString1) MessageBox("Formatted date 2", ls_dateString2) MessageBox("Formatted date 3", ls_dateString3) |
you can use the Date()
function to convert a string value to a date. Here’s an example:
1 2 3 4 5 6 7 8 9 10 11 12 |
// Declare a string variable string ls_dateString // Assign a value to the string variable ls_dateString = "03/17/2023" // Convert the string to a date date ld_myDate ld_myDate = Date(ls_dateString, "MM/dd/yyyy") // Display the date value MessageBox("String as date", String(ld_myDate)) |
Good Luck!
Subscribe
Login
0 Comments
Oldest