473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Date Formatting problem

Hi,

I have an ASPX page with a textbox where the user enters a
date.

I have a variable of tyope date that I populate from teh
form
d

dtMyDate = Request.Form("txMyDate")

I then call a function that formats my date.

Public Function FormatDate(ByVal dtMyDate as date) as Date

FormatDate = Format(dtMyDate, "mm/dd/yyyy")
End Function
If I pass in the date 01/01/2003, it formats it as
00/01/2003.

Any ideas why this is.

Thanks,
Kerri.
Nov 17 '05 #1
3 1118
Kerri wrote:
Public Function FormatDate(ByVal dtMyDate as date) as Date

FormatDate = Format(dtMyDate, "mm/dd/yyyy")
End Function
If I pass in the date 01/01/2003, it formats it as
00/01/2003.

Any ideas why this is.


Your function does not really do any formatting, since it returns a
"Date" datatype, which is not formatted. If it returned a string, then
it should work.

I also thought the correct syntax was:
return Format(dtMyDate, "mm/dd/yyyy")

If it compiles, I guess its fine, but I like the "return" syntax better
than the old VB6 syntax that you are using, mainly because it is easier
to read, and makes renaming the function much simpler.

Nov 17 '05 #2
yop
Hello

I saw this and found it works perfect.

Dim rightNow As DateTime = DateTime.Now
Dim sDateTime As String

sDateTime = rightNow.ToString("MM/dd/yyyy")
-----Original Message-----
Hi,

I have an ASPX page with a textbox where the user enters adate.

I have a variable of tyope date that I populate from teh
form
d

dtMyDate = Request.Form("txMyDate")

I then call a function that formats my date.

Public Function FormatDate(ByVal dtMyDate as date) as Date
FormatDate = Format(dtMyDate, "mm/dd/yyyy")
End Function
If I pass in the date 01/01/2003, it formats it as
00/01/2003.

Any ideas why this is.

Thanks,
Kerri.
.

Nov 17 '05 #3
"mm" in date format string means minute, not month. Month is what yop used,
MM.

Jerry
-----Original Message-----
Hi,

I have an ASPX page with a textbox where the user enters

a
date.

I have a variable of tyope date that I populate from teh
form
d

dtMyDate = Request.Form("txMyDate")

I then call a function that formats my date.

Public Function FormatDate(ByVal dtMyDate as date) as

Date

FormatDate = Format(dtMyDate, "mm/dd/yyyy")
End Function
If I pass in the date 01/01/2003, it formats it as
00/01/2003.

Any ideas why this is.

Thanks,
Kerri.
.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ray | last post by:
Date problem. Using non American date formats with Microsoft Access and Visual Basic. I set my regional settings to English(Ireland) or English(United Kingdom) and my date appears in Access as...
3
by: Ed | last post by:
Hi there, My problem is the following: When I assign a custom formatted Date & Time to a Date variable it loses it’s formatting. Ex. 2005-06-07 15:46 now when I assign this to a variable of...
7
by: Andy Davis | last post by:
I have a table of data in Access 2002 which is used as the source table for a mail merge document using Word 2002 on my clients PC. The data is transferred OK but I've noticed that any dates which...
12
by: Rob T | last post by:
I'm storing a date/time into a SQL table of type datetime. I need it to be precise so the value is stored to the 1000th of a second. ie "insert into myTable mydate values ('08/05/2005...
2
by: Thomas Beyerlein | last post by:
I am binding dates to a textbox, the date is stored in SQL in a datetime field. When it gets bound it turns it into a long date (Sunday, Dec. 25 2005), in SQL when viewing the table it views as a...
2
by: johndcal | last post by:
Hello All, I have a date value that I pull from a .csv file. After reading the file and storing the values in an array the value of the date could be found in $array, for example....
3
by: RJA | last post by:
Hiyas, Using VS .net 2003. Setting up a Webservice that accepts 3rd party vendor designed XML requests and returns a filled XMLDocument with response data. Vendor XSDs were serialize into...
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
7
by: creative1 | last post by:
Hello everyone. I am experiencing a strange problem that I can't fix on my own. I think I need expert's suggestions for this. The problem is: I want to print account statement (or any other...
9
by: Martin | last post by:
I'm retrieving some records from a database. One of the fields contains a date/time. I would like to format it as I send it out to the table in the displayed page. Can some one please tell me...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.