-
June 16th, 2008, 06:55 AM
#1
Re: VB6.0 Date Format
i have create two text boxes and a command buttom. in text1 i put 01/06/2008. i want in text2 it will display 01-may-2008. but it is showing 06-jan-2008. please help...
-
June 16th, 2008, 07:04 AM
#2
Re: VB6.0 Date Format
[ Split thread ]
Please do not post in old threads.
-
June 16th, 2008, 07:26 AM
#3
Re: VB6.0 Date Format
Originally Posted by sanjib294
i have create two text boxes and a command buttom. in text1 i put 01/06/2008. i want in text2 it will display 01-may-2008. but it is showing 06-jan-2008. please help...
? So you put in Jan 6 and you want it to display May 1 ?
If you are trying to modify the date then you need to give us a clue as to how you are trying to do it and what you are trying to accomplish.
btw May 1st would be written as 5/1/2008
Last edited by WillAtwell; June 16th, 2008 at 07:29 AM.
-
June 16th, 2008, 09:12 AM
#4
Re: VB6.0 Date Format
use DateAdd() to get the correct date in text2
-
June 18th, 2008, 07:14 AM
#5
Re: VB6.0 Date Format
i want to insert date from text box. suppose i have put text1 as 01/05/2008. i want it should be posted like 01-may-2008. but it is showing 05-jan-2008. is there any option to do so. But whenever i am trying to insert sysdate it is showing correctly.........Pls help
-
June 18th, 2008, 07:20 AM
#6
Re: VB6.0 Date Format
try this
Code:
Private Sub Command1_Click()
Text2.Text = Format(Text1.Text, "dd-MMM-yyyy")
End Sub
Framework 1.1
Windows application Development Using VB.Net
Visual Basic 6.0 and Crystal Reports
-
June 18th, 2008, 07:58 AM
#7
Re: VB6.0 Date Format
Originally Posted by sanjib294
i want to insert date from text box. suppose i have put text1 as 01/05/2008. i want it should be posted like 01-may-2008. but it is showing 05-jan-2008. is there any option to do so. But whenever i am trying to insert sysdate it is showing correctly.........Pls help
Well if I understand you correctly it sounds like you are either entering the date in the format of Day-Month-Year or your system is set to that format and you are entering Month-day-year. Either way the result is that the day and the month are reversed in your second field.
If you display the date using the date statement how is it displayed? mm/dd/yyyy or dd/mm/yyyy? WHich ever it is you need to use this format when entering a date or change the settings to the format you want to use.
-
June 18th, 2008, 08:35 AM
#8
Re: VB6.0 Date Format
Use this:
Code:
Dim splt() As String
splt = Split(Text1.Text, "/")
Text2.Text = Format(DateSerial(splt(2), splt(1), splt(0)), "dd-MMM-yyyy")
DateSerial() will return the date in system date format, hence no worry!
Riyaz
-
June 18th, 2008, 09:52 AM
#9
Re: VB6.0 Date Format
Originally Posted by Shaikh.Riyaz.a
Use this:
Code:
Dim splt() As String
splt = Split(Text1.Text, "/")
Text2.Text = Format(DateSerial(splt(2), splt(1), splt(0)), "dd-MMM-yyyy")
DateSerial() will return the date in system date format, hence no worry!
Riyaz
Seems like a waste of code.. If the user is entering a date in the first field then it is a simple matter of formatting it in the second field without need of calling anything other than the format.
The thing is that the date has to be entered in the format that is expected just as in the code above if the date is not entered exactly as expected it will not return the correct results.
Not that it is a big deal but there is no need to write the code to parse out the first text box but rather a need to determine the correct format for entering the date.
-
June 19th, 2008, 01:28 AM
#10
Re: VB6.0 Date Format
Originally Posted by WillAtwell
Seems like a waste of code.. If the user is entering a date in the first field then it is a simple matter of formatting it in the second field without need of calling anything other than the format.
Have your ever tried changing the regional settings for date?????
Originally Posted by WillAtwell
The thing is that the date has to be entered in the format that is expected just as in the code above if the date is not entered exactly as expected it will not return the correct results.
For exact output, there must be exact input and hence people write
long validation codes for GUIs.
-
June 23rd, 2008, 06:58 AM
#11
Re: VB6.0 Date Format
This takes a normal date format and converts it to serial number.
Dim intYear As Integer
Dim intMonth As Integer
Dim intDay As Integer
Dim lngSerial As Long
Dim strNewDate As String
Dim datDate As Date
datDate = CDate("01/05/2008")
intYear = Year(datDate)
intMonth = Month(datDate)
intDay = Day(datDate)
lngSerial = DateSerial(intYear, intMonth, intDay)
This converts a long integer representing a valid date into an accepted date format.
strNewDate = CDate(Format$(lngSerial, "dd-MMM-yyyy"))
Good luck.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|