Showing Date in a specific format - mysql

I need to make the date format that I entered into the database look exactly the same as when i view it. Eg. Currently my format is 2013-12-21, but when i view it, it shows 12/21/2013. It's quite confusing because when I edit the date in my form, it's in the 12/21/2013 format and the database wont accept it when i change the date to something like 12/23/2013. Please help. Thanks
(btw, it just auto formatted my date. I didn't even use the <%formatdatetime%> function.)
EDIT: Sorry for the lack of information guys. This is what's happening.
1. I created a form to add date amongst othes to mysql. Eg. Purchase date, item, etc (sql wants it in yyyy-mm-dd format and that's how i enter it.
2. created a view list to select which rows i want to update. (Used
<%=Formatdatetime(f_purchasedate,2)%>
to show date only without time as it was 12/21/2013 12:00:00 AM)
3. created an update form.
Now the problem is it shows the date as 12/21/2013 instead of 2013-12-21. So when i submit the form after altering other fields, it says date error. I have to manually type the format 2013-12-21 for all my dates before i can submit the form.
i'm guessing it has something to do with this line of mine.
purchasedate.Text = ODBCdataset.Tables("tbl_vm").Rows(0).Item(2)
tried this but it doesnt help either...
formatDateTime('purchasedate').Text.ToString("yyyy-MM-dd") = ODBCdataset.Tables("tbl_vm").Rows(0).Item(2)

You can use DATE_FORMAT(date,format)
Select DATE_FORMAT('Your Date Value'),%Y-%m-%d) as Date from table_name
Or
You can pass the value to a variable like below
purchasedate.Text = CType(ODBCdataset.Tables("tbl_vehiclemanagement").Rows(0).Item(2).ToString, DateTime).ToString("yyyy/mm/dd")

Dim date As String = DateTime.Now.ToString("yyyy/mm/dd")

Related

Date/Time formatting in access textbox

I have an issue, and believe its simple to resolve but cant work out how.
My table, which has showing both date & time can not be amended because that is how I receive my data.
Ive changed the format in the table design to short date and it shows fine, it hides the time.
I also changed the textbox that displays the date to short date but its still showing both the date and time, why?
Primarily, I have another textbox that I want to calculate the table date + 30, my expression used is:
=[text5]+30
The textbox is displayed blank.
Any help?
It sounds like your date field is linked as text. So convert to Date:
=DateValue([OpenedDate])
and for the +30 date:
=DateAdd("d",30,DateValue([OpenedDate]))
However, there is no way that:
? DateValue(Now() + 30)
can show today's date. It will show 30 days ahead of today.

calculate date expression and update table in access

I have a form based on a table.
I have a purchase_date field and an expiry_date field.
I want expiry_date to add 6 months to purchase_date (in my form) and then insert this value into the table.
I have created this expression: DateAdd("m",6,[purchase_date]) as the control source of expiry_date. This works as expected but this value is not being updated/ saved from the form into the table. I have tried using onClick and afterUpdate functions to run the expression but no joy.
Thanks for any help.
Have you tried OnSave? Your dateadd syntax seems ok. Watch out for any protected cells/sheets! You can generally use activesheet.unprotect if this is the case.
Also, activesheet.calculate might help you, if correctly placed in your VBA.

MS Access stores the date as 30/12/1899 and not the actual date

whenever I am pushing the data from VBA code to an Access table the date field is stored as 30/12/1899 and not the actual date ? I tried formatting the date to mm/dd/yyyy before writing to the table but no success. Thanks in advance for the help
In VBA you need to use US date format AND surround the date with # signs so today would be
#02/20/2015#

dd/mm/yyyy date format in SSRS

i'm trying to specify dd/mm/yyyy dateformat for date/time parameter in SSRS 2008 R2.
My computers datetime format is mm-dd-yyyy.
My requirement is, i want to show date format at dd/mm/yyyy irrespective of the system/server date format.
I've already tried CDate(Format(Today,"dd/mm/yyyy")) which didn't work. one very strange thing i observed is, it shows dd/mm/yyyy format only for dates on or before 12-MM-yyyy, and 13 onwards it gives error: Conversion from string '25-04-2014' to type Date is not valid. (Possibly it is trying to map 25(daypart) with MM-dd-yyyy (month part)) which is out of range of total months i.e. 12)
my research on internet says it is a bug in BIDS 2008.
What do i do to display date as dd/mm/yyyy ??
I don't have enough reputation to comment, but I did notice that you failed to put "()" after "Today". If I'm not mistaken you must put Today() for that function to work. Also, you might want to try putting CDate Around the Today() function. You shouldn't need it, but it's worth a shot. Also, for some odd reason, in my experience, you must capitalize MM for format to work correctly.
Like #Aditaya said, it should be =format(Today(),"dd/MM/yyyy")
The expression I usually use is:
=FormatDateTime(Fields!Date.Value, DateFormat.ShortDate)
However, this may be region specific.
Rather than writing an expression to do the formatting, you can also use the Textbox Format Property. But first you need to make sure that the data is in a date format. So use the CDate function on your column like this:
=CDate(Fields!Date.Value)
Then in the textbox properties go to the Number tab. Select Date for the category. Then you can select whichever format you want or use a Custom format. This will change how the column displays when you run the report.

Can I create Date entry control with date separator for classic ASP

I was using a calendar control for entry of date in a classic-ASP application. But calendar control is not keyboard friendly and take more time for data entry. So later I added a simple text box with date validation. It works fine. However, the user need to put the date separator also. I wish to put a date entry field that comes with a pre-configured date format and separator, so that the user simply type on the numbers and the field cause a validation as well.
How can I achieve this?
Just use jQuery/javascript to mask the date text field. It will automatically format the date as the user enters the values. Also forces correct validation as it works.
for example jQuery plugins search for :
jquery date mask: http://digitalbush.com/projects/masked-input-plugin/
You can always put three text boxes with the separator as text (as I do in an old ASP classic site)
You need to separate the date in the response and then join it using DateSerial when posted.
When we've created something similar in the past we've allowed the user to enter a date into a textbox in a couple of different ways:
DDMMYYYY
D/M/YYYY
0 (for today)
When the form is submitted we had a simple ASP function to convert DDMMYYYY into DD/MM/YYYY (date string must be 8 characters though because the assumption was 2 digits for DD, insert the separator, 2 for MM, etc.) and check this was a valid date, and an if formdate = 0 then formdate=now() rule.
You need to add some JavaScript validation on the form too though. On the textbox add an onblur event to check for the same things - either 8 digits entered, or a valid date, or a 0 - otherwise alert the user. (I would do this in jQuery if we were redoing it today)
You can get quite helpful with the Javascript "validation" to speed up data-entry if you wanted to, for example if a lot of dates being entered are yesterday or tomorrow allow a -1 or +1, or if data entry is always for the current month but a different day, allow the user to just enter a number - 15 and the Javascript/jQuery converts the string to 15/03/2011.
With HTML 5...textMode="Date"
<asp:TextBox ID="TextBoxDate"
runat="server"
CssClass="form-control" Width="561px"
TextMode="Date">
</asp:TextBox>