How to convert long date format (dddd, MMM d, yyyy) into date in UFT? - vba

I'm still new at UFT, but I've come across a problem that I haven't been able to figure out. I'm testing the web based portion of our application right now, and there's dates in all kinds of formats (dd/mm/yyyy, MMM d, YYYY, MMM yyyy)
The one I can't seem to convert to a date is (dddd, MMM d, yyyy).
I found this: ' In addition, a long date format is not recognized if it also contains the day-of-the-week string.' on the CDate function page for ADM help.
So I guess my question is, how do I handle this format? Do I remove the first word in the string? Is there another way to do this? - Thanks all for any help

Related

How to convert dates to valid format in Google Data Studio?

I have a google sheet with dates in europian format ( 15.09.2020 08:40 ) . When importing the sheet to data studio it detects this field as text. I try to change it to DATE but get error "Cant convert". Maybe becouse its in european format? Anyone know how to change this? I have tried formatting in google sheets with no luck...
You have to convert it yourself, with the european date as as string in the field your_field, create an additional field with following formula:
PARSE_DATETIME("%d.%m.%Y %H:%M:%S", your_field)
The details for date converting/parsing can be found here:
https://support.google.com/datastudio/answer/9739558

Crystal reports change date format

I am working on Crystal report 2013 and I'd like to format the date in crystal report
from
2008-04-27
to
April 27, 2008
what i have tried is this
Right click on the field -> Format Editor
Date and Time tab
Select date/time formatting you desire
but i can't see the date and time tab when i did this. I also use this formula below but no luck.
CSTR({StudentInformation.BirthDay}, "MM dd, yyyy")
Can anyone please help me to solve this. thanks
create a formula for your date and in your formula set it to totext( {StudentInformation.BirthDay}, "MMMM dd, yyyy" ), then add the formula to your report instead of the field
After having my research. This code solve my problem. It converts the string data type to Date and you can now easily format this according to your need.
DateValue({StudentInformation.BirthDay})

asp:boundfield dataformatstring not working

I am working on a vb.net web application and I am displaying a Gridview with rows containing datetime, the data is coming from database. In my aspx file, within my asp:boundfield I am trying to change the date format (which at the moment is mm/dd/yyyy hh:mm:ss) to "dd MMM yyyy" (no time) and I have tried using the dataformatstring and HtmlEncode="True/False" (both) but still it does not change the date format in the GridView. The code is as shown below -
<asp:BoundField DataField="STF_JOINED" HeaderText="Joined" SortExpression="STF_JOINED" HtmlEncode="False" DataFormatString = "{0:d}" ReadOnly="True">
In the above code I tried to format the date to shortdate for the moment but it didn't work. I would still want the date format to be in "dd MMM yyyy" format.
I have tried a number of solutions from stackoverflow but none of them seem to work for me. Can someone please tell me what I am doing wrong or what I should be doing, by giving a small example code.
You don't need HtmlEncode at all.
For DataFormatString You have to use, for example, {0:dd MM yyyy} or {0:dd.MM.yyyy} beacuse Your database field data type is datetime not date (where dd represent day, MM month and yyyy year. Be aware for MM, if You write mm it's represent minutes).
<asp:BoundField DataField="STF_JOINED" HeaderText="Joined" SortExpression="STF_JOINED" DataFormatString = "{0:dd MM yyyy}" ReadOnly="True">
Tested and working.
You can read more about data format strings here : BoundField.DataFormatString Property
There You can see examples for Standard and Custom format string (links under every table).

VBA getdate function (?)

I wonder if there's any function in VBA which convert strings into a date?
I mean I work with dates with different formats e.g. 20150723, 07023015, 23-07-15 etc. -it's the same date for me, but VBA editor does not know it:)
What's the best way to get "real" date 2015/07/23 from string 20150723 ?
For your specific example, you can use:
cdate(format("20150723", "0000-00-00"))
which converts "20150723" into "2015-07-23" which should be recognisable to CDate as a date string.

How to Format VBA TextBox To Long Date

I have a textbox for date display which shows the date in this format: 17/04/2012 but I would like to format it to shows up like 'April 17, 2012'. I tried this code
UserForm1.txtDate = Format(Long Date)
which I am getting syntax error from compiler.Can you please let me know how I can do it?
Thanks
there have been couple of posts on this. Culprit seems to be your system date format. Use of short, medium, long formats will change the result when the system settings change.
In US systems mainly it's done as, e.g. Format$(yourdate, “dd/mm/yyyy”)
Where as European systems, e.g. Format$(yourdate, “short date”)
If we look at explicitly defining your format, you are formulating your regional settings!
Good e.g. short date won’t always be mm/dd/yyyy but could be dd/mm/yyyy. That’s the key advantage over actually specifying the format. Simply you can change how you want your date to look like instead of depending on the system (with or without your knowledge).
When we first encountered this, we had some making the VBA apps and sending it over to another in some other place where they have own localized system date format. Your phone rings... ;)
Short/Long Date: Display a date according to your system’s long date format.
Medium Date: Display a date using the medium date format appropriate for the language version of the host application.
In your case you could use,
UserForm1.txtDate.Value = Format$(Date,"mmmm dd, yyyy")
Or to be super-safe,
Dim dtDate as Date
dtDate = DateSerial(Year(Date), Month(Date), Day(Date))
UserForm1.txtDate.Value = Format$(dtDate, "mmmm dd, yyyy")
Hope that helps.
References