Midday / Midnight

Guy Boswell

Registered User.
Local time
Today, 15:51
Joined
Jul 20, 2009
Messages
26
I am writting a module that generates scripts for flood warning messages. The text, once produced, goes to another system outside Access for telephone distribution via voice synthesis. Someone else has done all that clever technical stuff. All I need to do is produce the script as a text file.

Each message includes the date and time it is recorded. I have a little bit of code that takes now() and rounds it up to the next five-minute interval. So for example a script produced at 10:27:16 will say, "This message was recorded at ten thirty a m ...". I want all times in twelve hour clock format.

My problem is midday and midnight. There is a chance (1:144!) that a message will appear to be issued at exactly midday or midnight. In which case I want the message to say, "This message was recorded at midday ...". 12:00, 12:00 am or 12:00 pm can all be rather ambiguous! :(

So what I want is a format that takes a date time input and outputs text with the time replaced by the word midday or midnight if appropriate. Is there a format built in to Access that will do that? Or do I need to write a function?

Grateful for any help. Thank you :)
 
i am not sure what you mean - the times are different, and easy to distinguish for a programme - but i apprecaite there is a real ambiguity.

(even deciding whether midnight is midnight yesterday, or midnight today, if you see what i mean.)

but
midnight is time 0
midday is half way through a day, so is actually 0.5 days

what does your function return - a date, or a string

if it returns a date, then you cant get midnight/midday, just the date value - if its a string, then you can do what you want. It also depends what your speech app is expecting.
 
Hi Dave, Thank you for the reply. Yes, I agree there is no ambiguity for the program and there are agreed conventions on how to interpret 00:00/12:00/24:00 etc. But not everyone knows them. So I want the final voice message to specifically say midday or midnight if that is appropriate.

I have a function, funcRoundUpTime(datTimeToBeRounded) that returns a date/time rounded up to next five minutes.

My final product is a text file so I need to add in something like,

Script = "This message was issued at " & Format(funcRoundUpTime(Now),"midday/midnight format") & " and represents the situation at that time."

So if now = 23:57 it would return Script = "This message was issued at midnight and represents the situation at that time."

The speech app interprets, "This message was issued at 00:00", as, "This message was issued at zero hundred hours", and interprets, "This message was issued at 12:00", as, "This message was issued at twelve o'clock". That is pretty good but not quite what I want.
 
It seams to me that the speech interpreter needs amending. I would suggest sending the time expressed as minutes past midnight and get the interperter to evaluate the correct teminology. So if you sent "This message was issued at 1435 and represents the situation at that time" should be evaluated to "This message was issued at 11:55pm and represents the situation at that time" likewise "This message was issued at 720 and represents the situation at that time" should be evaluated to "This message was issued at 12 noon and represents the situation at that time".

David
 
Cheers David, I like your thinking - make it someone elses problem! Unfortunately the speech interpreter is a given - I can't get that changed.

It's Ok - I can write my own function to interpret a date as a string the way I want it - it would just have been easier if there was a prefined format.
 
i think you just need an if or case construct, in your time handler

effectively

if time = 0 then ... midnight special case
if time = 0.5 then ... midday special case
else use the time normally
 
I ended up doing:
'Work out time string
strTime = Format(datDateTime, "h:Nn am/pm")
'Change time string for midnight
If datDateTime - Int(datDateTime) = 0 Then strTime = "midnight"
'Change time string for midday
If datDateTime - Int(datDateTime) = 0.5 Then strTime = "midday"
Thank you for helping me think it through.
 

Users who are viewing this thread

Back
Top Bottom