| |

VerySource

 Forgot password?
 Register
Search
View: 1170|Reply: 7

Date conversion problem in sql server

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-12-16 13:00:01
| Show all posts |Read mode
To develop a database with VC, you need to get the date in two edit boxes, one for the year and the other for the month. For example: 2017 1
To convert the input character into a date type, the code: convert(datetime,'yyyy-mm') An error message appears when an error occurs when converting the character to datetime. Please help to change it!
Reply

Use magic Report

0

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-12-16 13:15:01
| Show all posts
'yyyy-mm' changed to'yyyy-mm-dd'
Reply

Use magic Report

1

Threads

23

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-12-16 16:00:02
| Show all posts
Is it converted in VC or in database?
Reply

Use magic Report

0

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-12-16 16:15:01
| Show all posts
Date format must include date
Reply

Use magic Report

0

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-12-16 16:30:01
| Show all posts
Is to include the year, month, and day
Reply

Use magic Report

0

Threads

88

Posts

55.00

Credits

Newbie

Rank: 1

Credits
55.00

 China

Post time: 2020-12-17 08:45:01
| Show all posts
select convert(datetime,'2020-01-01')
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-12-18 19:45:01
| Show all posts
sql.Format("select start_time,end_time from leave_info_tab "
"where personID='%s'and"
"start_time> (convert(datetime,'yyyy-mm-dd' )) "
"and end_time<(convert(datetime,'yyyy-mm-dd' )) ",
strPersonID,strMonthStart,strMonthEnd);
This is a part of the statement, and an error appears when an error occurs when converting from a character to a datetime
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-12-21 11:15:01
| Show all posts
strMonthStart and strMonthEnd are not called in it, they must be called separately in the convert
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