| |

VerySource

 Forgot password?
 Register
Search
View: 780|Reply: 8

Datetime type is accurate to hours, minutes and seconds, how to remove minutes and seconds

[Copy link]

6

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-2-18 21:00:02
| Show all posts |Read mode
Datetime type is accurate to hours, minutes and seconds, how to remove minutes and seconds
Reply

Use magic Report

0

Threads

14

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-4-23 14:45:01
| Show all posts
select getdate ()

select convert (char (10), getdate (), 120)
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-4-23 20:15:01
| Show all posts
select convert (char (8), getdate (), 108)
--result
--------
22:46:56

(1 row (s) affected)


select convert (char (10), getdate (), 120)
--result
----------
2017-01-04

(1 row (s) affected)
Reply

Use magic Report

0

Threads

100

Posts

53.00

Credits

Newbie

Rank: 1

Credits
53.00

 China

Post time: 2020-4-23 21:00:02
| Show all posts
select convert (char (13), getdate (), 120)
Reply

Use magic Report

0

Threads

100

Posts

53.00

Credits

Newbie

Rank: 1

Credits
53.00

 China

Post time: 2020-4-23 22:00:01
| Show all posts
Do you want hours?
Reply

Use magic Report

6

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Hong Kong

 Author| Post time: 2020-4-24 11:00:01
| Show all posts
Hero, you explain what char (13) 120 means
Reply

Use magic Report

0

Threads

100

Posts

53.00

Credits

Newbie

Rank: 1

Credits
53.00

 China

Post time: 2020-4-24 13:15:01
| Show all posts
Convert the date to a character type, take the first 13 digits, 120 refers to the format at the time of conversion: yyyy-mm-dd hh: mm: ss [.fff]-[. Fff] refers to milliseconds
Reply

Use magic Report

6

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-4-24 16:45:01
| Show all posts
Thanks, hero, I get it, and ask another question
Regarding the money type, can you directly determine the number of decimal points when building a table, such as two decimal places
Reply

Use magic Report

0

Threads

100

Posts

53.00

Credits

Newbie

Rank: 1

Credits
53.00

 China

Post time: 2020-4-24 21:45:01
| Show all posts
Monetary data represents positive or negative monetary values. Use the money and smallmoney data types to store monetary data in SQL Server. The accuracy of monetary data storage is four decimal places.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list