且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

需要将文本转换为时间

更新时间:2023-12-05 11:19:52


hmm ...


我有类似的东西,但在我的情况下,这将无法正常工作。我有一个文本字段,以这种格式存储mins的值000100表示​​1分钟。


我需要将其分解为时间参考00:01:00以便我可以使用它计算花费的总时间。


我尝试了几种不同的日期/时间功能,但它们都添加了我不需要的日期。


问题是:有没有办法将此文本转换为仅限时间字段?


即持续时间/持续时间

005005 ... 00:50:05

000905 ... 00:09: 05

001500 ... 00:15:00


总计01:14:10


谢谢你帮忙!



尝试>>>>> TimeValue([YourDateTimeField])



hmm ...


我有类似的东西这个,但在我的情况下,这将无法正常工作。我有一个文本字段,以这种格式存储mins的值000100表示​​1分钟。


我需要将其分解为时间参考00:01:00以便我可以使用它计算花费的总时间。


我尝试了几种不同的日期/时间功能,但它们都添加了我不需要的日期。


问题是:有没有办法将此文本转换为仅限时间字段?


即持续时间/持续时间

005005 ... 00:50:05

000905 ... 00:09: 05

001500 ... 00:15:00


总计01:14:10


谢谢你帮忙!



可能最简单的方法是进入表设计视图并将列持续时间更改为长时间的输入掩码。掩码最终看起来像这样:99:00:00 \> LL; 0; _


这也将确保在此字段中输入的任何未来数据符合同样的格式。


问候,

Scott


啊,是的,我同意你们两位关于更改数据类型的问题但是,问题的一部分是,我正在使用专有程序,而我使用的数据库是实时数据库的只读副本。


所以我必须转换它在查询中;直接查询或追加查询


我甚至尝试修改内置函数:


TOD:TimeSerial((小时) (左([持续时间],2),(中([持续时间],3,2),(中([持续时间],5,2))))


并获得类型不匹配错误......当然有一种方法可以实现这一点。


< edit>只是为了确保我再次尝试了时间值,它只是在列中显示错误

hmm...

I have something similar to this but in my case this will not work. I have a text field storing the value in mins in this format 000100 representing 1 min.

I need to break this into a time reference 00:01:00 so that I can use it to calculate total time spent.

I have tried several different date/time functions but they all add the date, which I do not need.

question is: is there a way to convert this text into a time only field ?

i.e. Duration time/duration
005005 ... 00:50:05
000905 ... 00:09:05
001500 ... 00:15:00

total 01:14:10

thanks for you help!

hmm...

I have something similar to this but in my case this will not work. I have a text field storing the value in mins in this format 000100 representing 1 min.

I need to break this into a time reference 00:01:00 so that I can use it to calculate total time spent.

I have tried several different date/time functions but they all add the date, which I do not need.

question is: is there a way to convert this text into a time only field ?

i.e. Duration time/duration
005005 ... 00:50:05
000905 ... 00:09:05
001500 ... 00:15:00

total 01:14:10

thanks for you help!

Try >>>>> TimeValue([YourDateTimeField])


hmm...

I have something similar to this but in my case this will not work. I have a text field storing the value in mins in this format 000100 representing 1 min.

I need to break this into a time reference 00:01:00 so that I can use it to calculate total time spent.

I have tried several different date/time functions but they all add the date, which I do not need.

question is: is there a way to convert this text into a time only field ?

i.e. Duration time/duration
005005 ... 00:50:05
000905 ... 00:09:05
001500 ... 00:15:00

total 01:14:10

thanks for you help!

Probably the easiest way is to go into the table design view and change the input mask for your column Duration to Long Time. The mask will end up looking like this: 99:00:00\ >LL;0;_

This will also ensure that any future data entered in this field conforms to the same format also.

Regards,
Scott


Ahh yes I agree with both of you in regards to changing the data type in the table, however, part of the problem is that I am working with a proprietary program and the DB I use is a read only copy of a live DB.

so I have to convert it in the query; either a straight query or an append query

I even resorted to trying to modify a built in function:

TOD: TimeSerial ((Hour(Left([duration],2), (Mid([duration],3,2), (Mid([duration],5,2))))

and get a type mismatch error...surely there is a way to accomplish this.

<edit>just to be sure I tried the timevalue again and it just shows an error in the column