Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting files with starting date and ending date 1

Status
Not open for further replies.

rresendez

Programmer
Mar 14, 2005
40
US
I am trying to select records by using a starting date and an ending date. I have to get all the records from one date to another. The dates and not set dates. My code ask for the s_date and e_date and they are both =date() which seem to want to say the date with 2005 (03/17/2005) instead of 05 (03/17/05, but when you enter in a date you can only enter the 05. I searched the posts, but found nothing to help me. Any ideas?

Thanks,
Ramon
 
have you tried SET CENTURY ON?

hope this helps. peace! [peace]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Thanks Kilroy, I SET CENTURY ON and found out that the century must have been set for 19 because today's date showed up as 03/17/1905. So I SET CENTURY TO 20. I used this test program just to try it out:



CLEAR

SET DATE TO MDY
SET CENTURY ON
SET CENTURY TO 20

pre_date=DATE()
post_date=DATE()

@5,10 SAY "Starting date: " GET pre_date
READ
@7,10 SAY "Ending date: " GET post_date
READ

USE transactions
GO BOTTOM

dcount=1
tot_count=RECNO()
tot_count=tot_count+1

DO WHILE dcount<tot_count

GOTO dcount

IF t_date>=pre_date .AND. t_date<=post_date
? hc_num
?
? t_date
ENDIF

dcount=dcount+1

ENDDO

WAIT




 
What version of FoxPro are you using? Recent versions should default to 2005.

Tamar
 
Visual Foxpro 5. I was shocked ot see it was 19 and not 20. I must have done something or maybe it is a problem with vfp 5.

Thanks,
Ramon
 
Geoff,

That gives you the system date regardless of any VFP setting so it would mean that Windows has its date wrong.

No. Ramon's getting 1905 because he's using VFP 5.0. Remember, SET CENTURY ... ROLLOVER was introduced in 5.0, but it was not set by default (unlike in 6.0), so the century always defaults to 19.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Ramon,

I was shocked ot see it was 19 and not 20.

This was the correct behaviour in VFP 5.0.

VFP has its roots in the old xBase family of products, which date back to the late 1970s. In xBase, the rule was that if you enter a date with only two digits for the year, the century will default to 19.

VFP 5.0 introduced SET CENTURY ... ROLLOVER. For example, SET CENTURY 19 ROLLOVER 45 means that 00 to 45 will be interpreted as 2000 to 2045, other years will be 19xx. However, you have to explicitly execute that command.

In later versions of VFP, SET CENTURY is executed automatically, the cut-off year being the current year minus 50.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
No. Ramon's getting 1905 because he's using VFP 5.0.

But Ramon is using the DATE() function and says "today's date showed up as 03/17/1905"

I don't have VFP 5 loaded on this PC but surely DATE() gives today's date from the system clock. I do have FPW26 here and ?DATE() puts 18/03/2005 on screen.

Geoff Franklin
 
Geoff,

But Ramon is using the DATE() function and says "today's date showed up as 03/17/1905"

Did he say that? I thought he was talking about entering dates in a textbox ... oh, wait. You're right. He's got some code to put DATE() in an @/SAY field. That's confusing.

So, if that's right and he is simply displaying DATE(), then it should definitely show the date as per the system clock.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Mike and Geoff,

I assure you that my system date was 2005. I have to go to the system Date/Time Properties to check on a date for an event the next year or two and it has always had the correct year.

I tried to set century back to 19 to see what it would do and it done nothing. The century stayed at 20. Also, I checked my Date/Time and can only go back to 1980 in my Windows 2000.

Apparently, I needed to change the century for the first time and it is corrected for ever. Maybe other users of VFP 5 need to do the same thing, if they haven't already.

Ramon
 
Ramon,

Now I'm really confused. You said:

I tried to set century back to 19 to see what it would do and it done nothing. The century stayed at 20.

But earlier you said the century was showing as 19.

It seems that you are saying that in Windows (i.e. Control Panel), you are seeing the century as 20. But in VFP, you do SET CENTURY TO 19, then display DATE(), adn the century still appears as 20.

If so, that's exactly what I would expect. SET CENTURY TO 19 only applies to the input of a date, and only where the year has only two digits. In no way can it affect the system clock.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Mike,

It kind of makes sence. Because the century was never set to 20, Foxpro defaulted to 19. And I never had Century On, It only took the system clock as 05. So, when I turned Century On, I could see what the problem was.

I might install the VFP 5 to my sister's computer and see what the date is on it and turn Century On. I would bet that it does the same thing on her computer. It seems like VFP 5 defaults to century 19. This all is kind of interesting.

Ramon
 
Ramon,

It seems like VFP 5 defaults to century 19.

But that's exactly what I've been saying.

But I'm still confused as to whether you are talking about diplaying an existing date (as per your code where you are using @/SAY with DATE()), or letting the user enter a date.

I might install the VFP 5 to my sister's computer

By all means do that. But I think it would help a lot if you could also just summarise the problem as you see it. Perhaps if you could list the minimum steps you need to reproduce the problem, it might make things clearer all round.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Mike,

I was doing almost everything from the command window first. I did the following:


?date()
03/17/05
pre_date=date()
post_date=date()
?pre_date
03/17/05
?post_date
03/17/05
set century on
?pre_date
03/17/1905
?date()
03/17/1905
set century to 20
?date()
03/17/2005

Then my problem was solved.

Ramon

 
Ramon,

Then my problem was solved.

If the problem is solved, that's fine. I'm still uncertain about what you were trying to do in the first place, but never mind. The important thing is that you have got it working.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Mike,

What I was trying to do was have the user enter in a starting date and then an ending date for a report. I gave s_date and e_date the value of date(). My problem was that at first it was having a input for mm/dd/yy and since it was still on Century 19, it would not work correctly. So, when I turned Century on and seen it was on century 19 and not 20, As soon as I changed Century to 20, my code worked fine.

You are right, at least it is working. But if anyone else has this problem, hopefully, they will see this posting and have their problem resolved.

Thanks again,
Ramon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top