I need to convert a string value to a date in a crystal report. As you know Crystal has a handy "in the period of" in the select expert. However I am unable to use it without converting. The string is only four characters (example: 0512) I am having trouble using the date value function since there is no day or a full value for the year. Any help would be appreciated!
相关问题
- Date with SimpleDateFormat in Java
- VBA local timezone adjustment
- How do you use java stream api to convert list of
- JSpinner.DateEditor in Java Not Respecting TimeZon
- Making Django queries with localized dates
相关文章
- MYSQL: How can I find 'last monday's date&
- Calculate number of working days in a month [dupli
- Get file created date in node
- Temporal Extraction (i.e. Extract date/time entiti
- Postgres String to Date EXAMPLE 10Apr77 to 10/04/1
- What is the best way to cleanup the resources used
- Date format conversion in JavaScript
- converting to timestamp with time zone failed on A
I don't think this can be done since Crystal requires the year to be four digits (YYYY). You will always get a "Bad Date Format" error. See this article on the date conversion. You could try and convert it to date on the database end. If your dates are all in the 2000 range, you could get crafty and create a formula that will "build" you a proper date format and then convert it to date.
Just manipulate the string into the proper format and use the CDate function. It doesn't look like the day number matters to you, so set it to the first of the month.
Assuming that 0512 means May 2012 your code should look something like this:
That returns a date of 1/5/12 using your sample value. You can then format it as needed.