473,385 Members | 1,863 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,385 software developers and data experts.

is there a way to force 2 digits month/day ?

59
I was wondering if theres a simple way to force 09 motnh insted of only 9...

not just adding a zero before since if it will be 10 -> 010 is not good for what I'm trying to do..

oh, maybe you have a better idea for what I'm trying: I'm trying to determine which date is latter... what I'm doing is adding the year month day as a big number like: 2007/9/10 -> 20070910
but if its not two digits, it wont be true "always"
eg: 2007931 > 2007101

if anyone have a better idea then mine i'll be happy to hear :))
Sep 10 '07 #1
9 9241
MikeTheBike
639 Expert 512MB
I was wondering if theres a simple way to force 09 motnh insted of only 9...

not just adding a zero before since if it will be 10 -> 010 is not good for what I'm trying to do..

oh, maybe you have a better idea for what I'm trying: I'm trying to determine which date is latter... what I'm doing is adding the year month day as a big number like: 2007/9/10 -> 20070910
but if its not two digits, it wont be true "always"
eg: 2007931 > 2007101

if anyone have a better idea then mine i'll be happy to hear :))
Hi

Idealy we need more information where the data is coming from and where you are using it, but would
Format(YourDateVariable,"yyymmdd")
do it ??


MTB
Sep 10 '07 #2
missinglinq
3,532 Expert 2GB
You don't need to do all this to determine which date is later, just compare the two dates!

If DateA > DateB Then

This code , for instance, compares two dates, DateA and DateB and sends up a message box accordingly. The code can be easily be modified to do whatever you want
Expand|Select|Wrap|Line Numbers
  1. Private Sub CompareDate_Click()
  2. If Me.DateA > Me.DateB Then
  3.   MsgBox "DateA Comes after DateB"
  4. ElseIf Me.DateB > Me.DateA Then
  5.   MsgBox "DateB Comes after DateA"
  6. Else: MsgBox "DateA and DateB are the same!"
  7. End If
  8. End Sub
Linq ;0)>
Sep 10 '07 #3
zivon
59
doh... : )
now I really feel stupid lol..
though I think I tried that before.

anyway, it works great, thanks ! saved me a lot of code space...
Sep 10 '07 #4
zivon
59
another question, does it work the same with SQL ?
Sep 10 '07 #5
zivon
59
: \
that doesn't really works...
it made a lot of problams to my program and I didn't understood why..
I checked on the immediate ?#11/8/2007# > #10/09/2007#
and it return true : <
Sep 11 '07 #6
istya
35
What date format are you using? In SQL I think you would need to format the date to have this work the way you expect.
Is it the 11th Aug 07 > 10th Sept 07 or 8th Nov 07 > 9th Oct 07?

I'm not sure what the function is for Access SQL but in ANSII standard it's
Expand|Select|Wrap|Line Numbers
  1. to_date(sysdate,'dd/mm/yyyy')
  2.  
Sep 11 '07 #7
FishVal
2,653 Expert 2GB
: \
that doesn't really works...
it made a lot of problams to my program and I didn't understood why..
I checked on the immediate ?#11/8/2007# > #10/09/2007#
and it return true : <
That does really work. ;)
SQL accepts dates in m/d/y format only.
The confusing point here is that Access silently corrects dates which could not be interpreted as m/d/y.
e.g.
You pass #1/2/7# meaning 1-Feb-07, Access treats it as 2-Jan-07
You pass #13/1/7# meaning 13-Jan-07, Access corrects it and treats as you've been expecting.
To make access user even more happy VBA behaviour on this issue is different.
As far as I know it depends on regional settings and correction logic is different from that in SQL.
e.g
#13/1/7# will be treated as 7-Jan-13.
Sep 11 '07 #8
zivon
59
I understand what the problam is...
MS access treat the date one time as m/d/y and one time as d/m/y
but I dont understand how do I force him to treat it as d/m/y only ?
Sep 12 '07 #9
FishVal
2,653 Expert 2GB
I understand what the problam is...
MS access treat the date one time as m/d/y and one time as d/m/y
but I dont understand how do I force him to treat it as d/m/y only ?
It is almost as difficult as to force it to get numbers in roman numerals.
Just use dates in m/d/y. "Format" and "DateSerial" function may help you in this issue.
Sep 12 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: msnews.microsoft.com | last post by:
Hey Guys, I was wondering if any of you could help me out with converting a single digit (ie: 1, 2, 3, etc) to double digits (ie: 01, 02, 03, etc). I am trying to convert the date in...
5
by: kevinrost | last post by:
Hello folks, Is there a way to always have a field populated with 4 digits even if three digits may sometimes be entered into it? I am using a table in which I import files that have 3 or 4...
2
by: =?Utf-8?B?Sm9lIFRhdmFyZXM=?= | last post by:
I am using the DateTime.Parse method to parse user entered dates. The dates can be just the year, Month-year and Month-day-year in a variety of formats in a variety of cultures. I immediately parse...
1
by: generaltomfoolery | last post by:
I've built a page that has a date box in it and have used javascript code to make a calender to insert a date into the box but on some dates the day and month are single digits e.g. 1/1/2008 (want it...
4
by: Paulo | last post by:
If I keep a hard sql statment to show all records from 1 to 31 of each month will get error on months where there are no 31 days, how can i know the last day of the month ? any sql function or just...
3
by: One | last post by:
Hi group - I want to do a SELECT based on a date range - but mySQL syntax expects the month range to be two digits. So I have converted the month to show the leading zero like this : ...
4
by: ofuuzo1 | last post by:
I have the following xml file and I want to concat the values and if a value is less that two digits, it is converted to two digits <date> <day>1 </day> <month>11</month> <year>2008</year>...
11
by: estantep | last post by:
Hello, I am trying to find out an alternate way to brute-force a variable length vector with different variable length contents. int chromossome int max_value_for_each_chromossome
7
by: bluemoon9 | last post by:
Hi, I have a field call MRN. The property is text and max length is 8. In the data entry form, I have it as a combo box names cboMRN. I would like to force user to enter exactly 8 digits, if user...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.