Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Databases
»
[SOLVED]DATEPART fails- New to Lazarus
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
FPGMAP accepts duplicates...
by
Zvoni
[
Today
at 02:04:09 pm]
How to read the values ca...
by
dodgex
[
Today
at 11:17:00 am]
TToolbutton: Dropdown men...
by
apeoperaio
[
Today
at 11:16:26 am]
FPC Unleashed (inline var...
by
creaothceann
[
Today
at 10:47:31 am]
Hint tools gives wrong hi...
by
Nicole
[
Today
at 10:43:50 am]
TA Chart Axes visibility ...
by
Nicole
[
Today
at 10:32:35 am]
Scripts to generate ofici...
by
marcov
[
Today
at 09:44:13 am]
Connecting to AzureSQL
by
paweld
[
Today
at 09:31:30 am]
Nothing but chaotic attem...
by
dbannon
[
Today
at 09:25:17 am]
How do 'with' statements ...
by
Thaddy
[
Today
at 09:14:38 am]
Pascal port of Unishox2
by
Okoba
[
Today
at 08:48:45 am]
Can I get the position an...
by
CM630
[
Today
at 08:38:48 am]
Windows API Hooking/DLL I...
by
tooknox
[
Today
at 06:49:16 am]
Can't access class in for...
by
egsuh
[
Today
at 06:44:12 am]
P.I.S.S. a PlugIn-framewo...
by
cdbc
[
Today
at 12:43:49 am]
Qt does not position form...
by
systemgvp
[
Today
at 12:08:36 am]
TBufferDataSet error on a...
by
eldonfsr
[May 11, 2026, 11:24:36 pm]
Work of exeptions, corrup...
by
LemonParty
[May 11, 2026, 09:13:35 pm]
Help with FPReport data b...
by
Dankan1890
[May 11, 2026, 09:05:18 pm]
Full MSVC/LLVM/MinGW COFF...
by
tooknox
[May 11, 2026, 08:27:49 pm]
Limiting Search in TSelec...
by
Bart
[May 11, 2026, 06:45:22 pm]
How to compare floating p...
by
creaothceann
[May 11, 2026, 02:14:30 pm]
Getting name / line of ca...
by
Thaddy
[May 11, 2026, 01:58:46 pm]
Label with multiple lines...
by
paweld
[May 11, 2026, 12:39:49 pm]
[Solved] TStringGrid disp...
by
jcmontherock
[May 11, 2026, 11:30:47 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED]DATEPART fails- New to Lazarus (Read 942 times)
What I can do
Full Member
Posts: 193
[SOLVED]DATEPART fails- New to Lazarus
«
on:
September 01, 2024, 07:33:50 pm »
OS:Windows 10@64
Lazarus:3.22
DB with *.mdb Access@32 bit
Project: Make a new temp Field upon query call
"aYMDate"
but all attempts failed,
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
Close
;
SQLQuery1
.
SQL
.
Text
:
=
'SELECT *, DATEPART('
yyyy
',ck_Date) as aYMDate From mytable'
;
SQLQuery1
.
ExecSQL
;
SQLQuery1
.
Open
;
«
Last Edit: September 02, 2024, 07:29:36 am by What I can do
»
Logged
tooldeveloper
Newbie
Posts: 5
Re: DATEPART fails- New to Lazarus
«
Reply #1 on:
September 02, 2024, 04:33:46 am »
Try the following instead:
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
Close
;
SQLQuery1
.
SQL
.
Text
:
=
'SELECT *, DATEPART('
'yyyy'
',ck_Date) as aYMDate From mytable'
;
SQLQuery1
.
Open
;
The 'yyyy' needs two single quotes at beginning and end. The ExecSQL method is only for executing a statement that doesn't return a result.
«
Last Edit: September 02, 2024, 04:44:20 am by tooldeveloper
»
Logged
What I can do
Full Member
Posts: 193
Re: DATEPART fails- New to Lazarus
«
Reply #2 on:
September 02, 2024, 04:55:30 am »
Thank you tooldeveloper
but...
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
SQL
.
Text
:
=
'SELECT *, DATEPART('
'yyyy'
',ck_Date) as aYMDate From mytable'
;
Tried two apostrophe and even tried quota but errored out both times
Logged
paweld
Hero Member
Posts: 1611
Re: DATEPART fails- New to Lazarus
«
Reply #3 on:
September 02, 2024, 07:30:39 am »
In MS Access, use quotation marks instead of an apostrophe as a string delimiter
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
SQL
.
Text
:
=
'SELECT *, DATEPART("yyyy",ck_Date) as aYMDate From mytable'
;
https://www.w3schools.com/Sql/func_msaccess_datepart.asp
Logged
Best regards / Pozdrawiam
paweld
What I can do
Full Member
Posts: 193
Re: [SOLVED]DATEPART fails- New to Lazarus
«
Reply #4 on:
September 02, 2024, 07:34:22 am »
Thank you, paweld
My problem was bad data.
I needed some working examples so I use ChatGPT to write some and it worked great.
«
Last Edit: September 02, 2024, 07:42:35 am by What I can do
»
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Databases
»
[SOLVED]DATEPART fails- New to Lazarus
TinyPortal
© 2005-2018