April 27, 2024, 07:25:38 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Working with dates

Started by Andy, August 21, 2013, 01:21:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Hi,

Just thought I would post this example on how to munipulate dates.

I cannot take any credit for this just thought I would pull it all together in one easy example.

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

AdrianFox

Thanks for posting this.  It is very 'elegant' and could be very useful. 

:)
Adrian Fox

Andy

Thanks Adrian,

So many people have helped me in the past including yourself, I just like to try and help anyone I can.

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Bill-Bo

August 23, 2013, 07:10:48 PM #3 Last Edit: August 23, 2013, 07:13:55 PM by Bill-Bo
andy,

Great program, but it is off one day. I checked with today's date, and
my wife's and my birthdates. All one day later.

If you make Sunday the first in your "DayNames=" instead of last,
everything works fine.

BTW. I enter the day and month with 2 digits each, and 4 digits for the
year.

Please add an option to do another date so you wont have to start
if for each one.

Thanks

Bill

Andy

Thanks Bill,

I have amended the program so you can see what happends to both dates, i.e. the one you enter and the
next day.

Also, if you press 'Y' at the end you can enter another date.  :)

Regarding the day being out by one, this is strange as it works for my birthday and all the other dates I have tested it with, it has never been out on my PC.

Before posting this I tested, tested and re-tested - wonder why you are showing out by one day

Strange  ???

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Bill-Bo

andy,

I do not need the next day stuff. What I was trying to get
across was that when I first ran your program it giving the
day of the week a day later that it was suppose to be.

I was born on a Friday. Your program said I it was Saturday.
My wife, Monday. Your program said Tuesday.

13 Dec 1946 was a Friday
23 Jul 1951 was a Monday

Whatever you did to the program, it is now giving the correct
day. But next day stuff is not need. I don't know how that
came about.

Bill

Andy

Hi Bill,

Are you sure you read the origional screen correctly?

It took a date you entered and then found the next day. it then told you what the next day (day of week) would be. Not the date you entered.

Maybe that's the confusion (and maybe I didn't make it clear enough).

Anyway, glad it's working for you now.

Andy.
:)


Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian

Funny, it crashes eventually for me. It shows "The next day is" for a few seconds,
and then asks to send a love letter to Microsoft. Dunno what that is...

Brian

Andy

Hi Brian,

Cannot understand why it crashes eventually, i'm using Win 7 32 bit on my pc.

I use the method that I posted in a couple of programs and they have never crashed on me.

One program is constantly working with dates as it is a staff rota solution for my friend.

When you say it "eventually" crashes - how many times do you use it before it happends? and what O/S are you using?

Re: sending a love letter to Microsoft - i presume you mean a crash report.

Please let me know and I'll try to figure it out.
Andy.


Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian

Hi, Andy,

I thought it was my fault, as I had it compiling as a Window, but it still crashes as a Console
It manages to print this line: PRINT " The next day is ", dj$, ".",mj$,".",yj$
hangs a couple of seconds, then brings up the MS error window. I keep looking, but I cannot see anything
Using Windows XP SP3

Brian

Andy

Hi Brian,

Well I spotted something, I wasn't passing a value to the year field needed to get the start of the year.

Attached is the corrected verrsion.

That said, I connected my old disk with XP service pack 3 (Home edition) and ran both versions - but still could not get it to crash?

Anyway, could you try the new attached version and let me know please.

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Brian

Andy,

Still doesn't work. If you enter 28 08 2013 (which is today, of course), it returns Monday,
instead of Wednesday

And it still crashes. Appended a version which has all the variables defined

Brian