
615 P.2d 251 (1980)
Joseph OGDEN, Appellant,
v.
STATE of Nevada, Respondent.
No. 11768.
Supreme Court of Nevada.
August 18, 1980.
Norman Y. Herring, Nevada State Public Defender, and J. Gregory Damm, Deputy State Public Defender, Carson City, for appellant.
Michael Smiley Rowe, Dist. Atty., Douglas County, Minden, for respondent.

OPINION
PER CURIAM:
The appellant seeks to have his conviction of possession of a controlled substance overturned. Three errors are assigned. First, that the trial court should have called for additional psychiatric examinations. Second, that the trial court abused its discretion in determining that the appellant was competent to stand trial. Finally, that *252 the appellant did not make a knowing and intelligent guilty plea.
1. NRS 178.415(1)[1] provides that the court shall appoint two physicians, at least one of whom is a psychiatrist, to examine a defendant when determining if he is competent to stand trial. In the present case, Dr. Gerow testified that Ogden was not competent to stand trial, whereas Dr. Molde testified that Ogden was competent to stand trial. When there is conflicting psychiatric testimony at a competency hearing, the trier of fact resolves the conflicting testimony of the witnesses. Doggett v. Warden, 93 Nev. 591, 572 P.2d 207 (1977). Furthermore, such findings will be sustained on appeal when substantial evidence exists to support them. Hunt v. State, 92 Nev. 536, 554 P.2d 255 (1976). Dr. Molde testified that Ogden was competent to stand trial. This testimony supports the court's decision.
2. The appellant vigorously argues that the court wrongfully relied upon a treating doctor's letter. The record does not support this assertion since the trial court expressly discounted any reliance upon any evidence other than the testimony of Dr. Gerow and Dr. Molde.
3. Finally, the appellant contends that inconclusive testimony as to his mental condition at the time of the offense precluded him from knowing whether the alternative pleas of not guilty and not guilty by reason of insanity were available to him. This contention is without merit. The medical testimony received concerned only the appellant's capacity to stand trial and was irrelevant as to his mental state at the time of the act. Competency at time of trial is not to be confused with the defense of insanity. Competency to stand trial is a judicial determination, whereas the defendant's sanity at time of commission of the act is a factual question. By pleading guilty, the appellant gave up his right to a jury trial, Duncan v. Louisiana, 391 U.S. 145, 88 S.Ct. 1444, 20 L.Ed.2d 491 (1968), thus waiving his opportunity to raise the defense of insanity. State v. Bourdlais, 70 Nev. 233, 265 P.2d 761 (1954).
Affirmed.
NOTES
[1]  NRS 178.415(1) The court shall appoint two physicians, at least one of whom is a psychatrist or otherwise especially qualified, to examine the defendant.
